package file;

import java.io.File;
import java.io.FileFilter;

public class FileterDemo {
    public static void main(String[] args) {
        File dir = new File("src/main/java/file");
        if (dir.isDirectory()){
            FileFilter filter = new FileFilter() {
                @Override
                public boolean accept(File file) {
                    String name = file.getName().substring(0,1);
                    return name.equals("D"); //  contains():判断字符串是否包含指定字符
                }
            };
            File[] subs = dir.listFiles(filter);
            for (File sub:subs){
                System.out.println(sub.getName());
            }
        }

    }
}
